import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '优惠劵名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '商品ID',
    align: "center",
    dataIndex: 'goodsId'
  },
  {
    title: '商品名称',
    align: "center",
    dataIndex: 'goodsName'
  },
  {
    title: '开始时间',
    align: "center",
    dataIndex: 'beginTime'
  },
  {
    title: '结束时间',
    align: "center",
    dataIndex: 'endTime'
  },
  {
    title: '优惠劵类型',
    align: "center",
    dataIndex: 'type_dictText'
  },
  {
    title: '金额',
    align: "center",
    dataIndex: 'amt'
  },
  {
    title: '满减金额',
    align: "center",
    dataIndex: 'discount'
  },
  {
    title: '描述',
    align: "center",
    dataIndex: 'description'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'updateTime'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "开始时间",
    field: 'beginTime',
    component: 'DatePicker',
    componentProps: {
      showTime: false,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    //colProps: {span: 6},
  },
  {
    label: "结束时间",
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
      showTime: false,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    //colProps: {span: 6},
  },
  {
    label: "优惠劵类型",
    field: 'type',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_special_type"
    },
    //colProps: {span: 6},
  },

  {
    label: "状态",
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "valid_status"
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '优惠劵名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入优惠劵名称!' },
      ];
    },
  },
  {
    label: '商品ID',
    field: 'goodsId',
    component: 'Input',
    defaultValue: '0',
    componentProps: {
      disabled: true,
    },
    // dynamicRules: ({ model, schema }) => {
    //   return [
    //     { required: true, message: '请输入商品ID!' },
    //   ];
    // },
  },
  {
    label: '商品名称',
    field: 'goodsName',
    component: 'Input',
    defaultValue: '全部商品',
    componentProps: {
      disabled: true
    },
    // dynamicRules: ({model,schema}) => {
    //       return [
    //              { required: true, message: '请输入商品名称!'},
    //       ];
    //  },
  },
  {
    label: '开始时间',
    field: 'beginTime',
    component: 'DatePicker',
    componentProps: {
      showTime: false,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入开始时间!' },
      ];
    },
  },
  {
    label: '结束时间',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
      showTime: false,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入结束时间!' },
      ];
    },
  },
  {
    label: '优惠劵类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_special_type"
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入优惠劵类型!' },
      ];
    },
  },
  {
    label: '金额',
    field: 'amt',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入金额!' },
      ];
    },
  },
  {
    label: '满减金额',
    field: 'discount',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入满减金额!' },
      ];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入描述!' },
      ];
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      dictCode: "valid_status"
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入状态!' },
      ];
    },
  },
  {
    label: '',
    field: 'pid',
    component: 'Input',
    defaultValue: "0",
    show: false
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '优惠劵名称', order: 0, view: 'text', type: 'string', },
  goodsId: { title: '商品ID', order: 1, view: 'text', type: 'string', },
  goodsName: { title: '商品名称', order: 2, view: 'text', type: 'string', },
  beginTime: { title: '开始时间', order: 3, view: 'datetime', type: 'string', },
  endTime: { title: '结束时间', order: 4, view: 'datetime', type: 'string', },
  type: { title: '优惠劵类型', order: 5, view: 'list', type: 'string', dictCode: 'nurse_special_type', },
  amt: { title: '金额', order: 6, view: 'number', type: 'number', },
  status: { title: '状态', order: 7, view: 'list', type: 'string', dictCode: 'valid_status', },
  createTime: { title: '创建时间', order: 8, view: 'datetime', type: 'string', },
  updateTime: { title: '更新时间', order: 9, view: 'datetime', type: 'string', },
  createBy: { title: '创建人', order: 10, view: 'text', type: 'string', },
  updateBy: { title: '更新人', order: 11, view: 'text', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}